using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// SuperList实例
/// Demo类，后续的Ui可以基于此范例进行开发
/// </summary>
public class SuperListModule : GameModule
{
    /// <summary>
    /// Ui自身对象
    /// </summary>
    public SuperListView superListView;

    /// <summary>
    /// 数据
    /// </summary>
    public SuperListModuleData superListModuleData;


    public override void Open()
    {
        if (superListModuleData==null)
        {
            superListModuleData = new SuperListModuleData();
        }
        superListView = ShowSuperListView();
        superListModuleData.Initialize();
        

    }

    public override void OnClose()
    {
        RemoveSelf();
    }

    public SuperListView ShowSuperListView()
    {
        if (superListView==null)
        {
            superListView = GameUi.Instance.ShowView((int)ViewId.SuperList) as SuperListView;
        }

        if (superListView != null)
        {
            superListView.SetModule(this);
            superListView.SetModuleData(superListModuleData);
            superListView.Initialize();
            superListView.UpdateView();
        }
        return superListView;
    }



    #region 请求和响应  成双出现
    public void SendXXXRequest()
    {
        //发送请求获取数据
    }

    public void OnXXXResponse()
    {
        //更新数据

        //如果Ui存在则刷新数据
        if (superListView != null)
        {
            superListView.UpdateView();
        }
    }

    public override void RemoveSelf()
    {
        if (superListView != null)
        {
            superListView.RemoveSelf();
            superListView = null;
        }
    }

    public override void AddAllResponseFun()
    {
        throw new System.NotImplementedException();
    }

    #endregion


}
